#include "tDataStore.h"

CPPUNIT_TEST_SUITE_REGISTRATION(tDataStore);

tDataStore::tDataStore()
{
}

tDataStore::~tDataStore()
{
}

void tDataStore::setUp()
{
}

void tDataStore::tearDown()
{
}

void tDataStore::writing()
{
    ds.populate();
    ds.commit();
}

void tDataStore::readaccounts()
{
    ds.populate();
    CA(ds.accounts[0].user == "general");
    CA(ds.accounts[0].pass == "general");
    CA(ds.accounts[0].type == General);

    CA(ds.accounts[6].user == "client1");
    CA(ds.accounts[6].pass == "client1");
    CA(ds.accounts[6].type == Client);
    CA(ds.accounts[6].ID == 718);
}

void tDataStore::readbookings()
{
    ds.populate();
    CA(ds.bookings[2].ref == 5678);
    CA(ds.bookings[2].name == "Ms Anne Chang");
    CA(ds.bookings[2].address == "#04-56, MMU, Johor, Malaysia, 765342");

    CA(ds.bookings[2].code == 33);
    CA(ds.bookings[2].destination == "North Pole");
    CA(ds.bookings[2].type == Great);

    CA(ds.bookings[2].startDate1 == "3Mar2014");
    CA(ds.bookings[2].endDate1 == "16Mar2014");
    CA(ds.bookings[2].startDate2 == "4Mar2014");
    CA(ds.bookings[2].endDate2 == "17Mar2014");

    CA(ds.bookings[2].special == "<none>");

    CA(ds.bookings[2].bookDate == "3Dec2013");
    CA(ds.bookings[2].status == Invalid);
    CA(ds.bookings[2].clientID == 556);
}

void tDataStore::readholidays()
{
    ds.populate();
    CA(ds.holidays[3].code == 44);
    CA(ds.holidays[3].destination == "Bermuda Triangle");
    CA(ds.holidays[3].type == Big);
    CA(ds.holidays[3].managerID == 1001);

    CA(ds.holidays[11].code == 40);
    CA(ds.holidays[11].destination == "Hokuriku, Japan");
    CA(ds.holidays[11].type == Great);
    CA(ds.holidays[11].managerID == 1002);
}

void tDataStore::find()
{
    ds.populate();
    CA(ds.findBookRef(5678) == 3);
    CA(ds.findUserID(718) == 7);
    CA(ds.findUserID(1001) == 3);
    CA(ds.findUserName("general") == 1);
    CA(ds.findHolCode(70) == 7);
}

void tDataStore::listclientbookings()
{
    ds.populate();
    deque<bookStruct> temp = ds.listClientBookings(556);
    CA(temp[1].ref == 3456);
}

void tDataStore::listholidaybookings()
{
    ds.populate();
    deque<bookStruct>temp = ds.listHolidayBookings(33);
    CA(temp[0].ref == 5678);
}

void tDataStore::hascolon()
{
    string test = "heuheuhe:2!#%!#%@!#6:!%!@#%@!";
    string test2 = "@#$^@$&Y@$HY#W%TJH253ujh23ujh";
    CA(ds.hasColon(test));
    CA(!ds.hasColon(test2));
}

void tDataStore::encoding()
{
    ds.decode();
    ds.encode();
    CA(true);
}